Skip to content

fix(workflows): reject bool / .inf catalog priority in workflow & step catalog loaders#3526

Open
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/workflow-catalog-priority-guard
Open

fix(workflows): reject bool / .inf catalog priority in workflow & step catalog loaders#3526
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/workflow-catalog-priority-guard

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

What

The WorkflowRegistry and StepRegistry catalog-config loaders parsed priority with:

try:
    priority = int(item.get("priority", idx + 1))
except (TypeError, ValueError):
    raise WorkflowValidationError(... "expected integer ...")

This misses two guards the base CatalogStackBase._load_catalog_config already has:

  • bool is an int subclasspriority: true was silently coerced to 1 instead of rejected.
  • int(float("inf")) raises OverflowError (not in the tuple) → priority: .inf crashed with an uncaught traceback instead of the clean expected integer error.

The two _coerce_priority helpers used by catalog add (to compute the next priority) had the same OverflowError gap.

Fix

Add the explicit bool check and OverflowError to both loaders (mirroring the base loader), and OverflowError to both _coerce_priority helpers (they return 0 for an uncoercible existing priority rather than crashing catalog add).

Test

Parametrized test_config_priority_bool_or_inf_rejected on both TestWorkflowCatalog and TestStepCatalog rejects priority: true/false/.inf — fails before (bool coerced to 1 / inf OverflowError), passes after.


🤖 Written with the assistance of Claude Code (AI). Bug self-found; fix/tests verified locally (fail-before / pass-after), ruff clean.

…catalog loaders

The WorkflowRegistry and StepRegistry catalog-config loaders coerced priority
with int() inside except (TypeError, ValueError), missing two guards the base
CatalogStackBase loader already has:
- bool is an int subclass, so 'priority: true' was silently coerced to 1;
- int(float('inf')) raises OverflowError (not caught), so 'priority: .inf'
  crashed with an uncaught traceback.
Add the explicit bool check and OverflowError to both loaders, and add
OverflowError to the two _coerce_priority helpers used by 'catalog add' (they
return 0 on an uncoercible existing priority instead of crashing).

Parametrized tests on both TestWorkflowCatalog and TestStepCatalog reject
priority true/false/.inf (fail before: bool coerced to 1 / inf OverflowError).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Rejects boolean and infinite priorities in workflow and step catalog loaders while preventing catalog add from crashing on infinite existing priorities.

Changes:

  • Adds explicit boolean validation and OverflowError handling.
  • Adds regression tests for loader validation.
Show a summary per file
File Description
src/specify_cli/workflows/catalog.py Hardens priority parsing and add-catalog coercion.
tests/test_workflows.py Tests invalid boolean and infinite priorities.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment on lines +379 to +380
except (TypeError, ValueError, OverflowError):
# OverflowError: int(float("inf")) — a ``priority: .inf``.
Comment on lines +699 to 702
except (TypeError, ValueError, OverflowError):
# OverflowError: int(float("inf")) — treat an uncoercible
# existing priority as 0 rather than crashing 'catalog add'.
return 0
Comment on lines +1340 to 1343
except (TypeError, ValueError, OverflowError):
# OverflowError: int(float("inf")) — treat an uncoercible
# existing priority as 0 rather than crashing 'catalog add'.
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants